package com.ss.android.article.base.feature.user.account.presenter;

import com.bytedance.common.utility.UIUtils;
import com.bytedance.retrofit2.Callback;
import com.bytedance.retrofit2.ResponseWrapper;
import com.google.gson.JsonObject;
import com.ss.android.account.model.AccountExtraEditResponse;
import com.ss.android.account.model.UserModel;
import com.ss.android.article.base.feature.user.location.model.LocationResult;

final class c implements Callback<AccountExtraEditResponse> {
    private final AccountEditPresenter a;

    c(AccountEditPresenter arg1) {
        this.a = arg1;
    }

    public final void onCacheResponse(ResponseWrapper<AccountExtraEditResponse> response) {
        UserModel v1_1;
        LocationResult v3 = null;
        String v1 = response.body.getMessage();
        JsonObject v0 = response.body.getData();
        if (this.a.h == null || !"success".equals(v1)) {
            if (v0 == null) {
            } else if (!v0.has("description")) {

            } else {
                UIUtils.showImageToast(this.a.mContext, v0.get("description").getAsString());
            }
        } else if (v0 != null && (v0.has("attrs"))) {
            Object v0_1 = v0.get("attrs");
            v1 = ((JsonObject) v0_1).has("area")
                    ? ((JsonObject) v0_1).get("area").getAsString()
                    : "";
            String v2 = ((JsonObject) v0_1).has("birthday") ? ((JsonObject) v0_1).get("birthday").getAsString() : "";
            if (!android.support.design.a.isTextEmpty(v1)) {
                this.a.h.getCurrentModel().setArea(v1);
            }

            if (!android.support.design.a.isTextEmpty(v2)) {
                this.a.h.getCurrentModel().setBirthday(v2);
            }

            if (!((JsonObject) v0_1).has("gender")) {
            } else {
                this.a.h.getCurrentModel().setGender(String.valueOf(((JsonObject) v0_1).get("gender").getAsInt()));
            }
        }
        AccountEditPresenter.a(this.a, true);
        AccountEditPresenter v2_1 = this.a;
        if (v2_1.e != null) {
            UserModel v0_2 = new UserModel();
            v0_2.setArea(v2_1.e.userLocation);
            v0_2.setBirthday(v2_1.e.userBirthday);
            v0_2.setGender(String.valueOf(v2_1.e.userGender));
            v1_1 = v0_2;
        } else {
            v1_1 = ((UserModel) null);
        }

        if (v1_1 != null && (v2_1.hasView())) {
            v2_1.mView.a(v1_1.getGender());
            v2_1.mView.c(v1_1.getBirthday());
            v2_1.mView.b(v1_1.getArea());
        }

        this.a.d = false;
        this.a.m = "";
        this.a.n = v3;
        this.a.l = "";
    }

    public final void onErrorResponse(Throwable throwable) {
        this.a.d = false;
        this.a.m = "";
        this.a.n = null;
        this.a.l = "";
    }
}

